﻿@model SimpleTaskManager.Domain.Entities.ReportHeader

@{
    ViewBag.Title = "Report Details";
}

<h2>Report Details</h2>

<fieldset>
    <legend>Report</legend>

    <div class="display-label">Name</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Name)
    </div>

    <div class="display-label">Creation Date</div>
    <div class="display-field">
        @Model.CreationDate.ToString("yyyy-MM-dd HH:mm:ss")
    </div>

    <div class="display-label">Created By</div>
    <div class="display-field">
        @(Model.CreatedBy.FirstName + " " + Model.CreatedBy.LastName)
    </div>

    <div class="display-label">Is Approved</div>
    <div class="display-field">
        @if (Model.IsApproved)
        {
             <span>@("Yes (by " + Model.ApprovedBy.FirstName + "  " + Model.ApprovedBy.LastName + ")")</span>
        }
        else
        {
            <span>No</span>
            if (ViewBag.CanApprove)
            {
                <span>| </span>
                @Html.ActionLink("Approve", "ApproveReport", 
                    new { taskId = ViewBag.TaskId, reportId = Model.ReportHeaderID });
            }   
        }
    </div>

    @if(Model.Details != null)
    {
        <div class="display-label">File</div>
        <div class="display-field">
            @if(ViewBag.CanOpen)
            {
                @Html.ActionLink(Model.Details.FileName, "ReportData",
                    new { taskId = ViewBag.TaskId, reportId = Model.ReportHeaderID });
            }
            else
            {
                @Html.DisplayFor(model => model.Details.FileName);
            }  
        </div>
    }
</fieldset>
<p>
    @Html.ActionLink("Back to List", "Reports", new { id = ViewBag.TaskId })
</p>
